# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from pydantic import BaseModel, Field


class DocsSettingIn(BaseModel):
    """ 文档配置参数 """
    status: int = Field(..., ge=0, le=1, description="功能开关: [0=关, 1=开]")
    auto_abstract: int = Field(default=0, ge=0, le=1, description="自动摘要: [0=否, 1=是]")
    charge_method: int = Field(default=0, ge=0, le=2, description="收费方式: [0=免费, 1=模型, 2=固定]")
    charge_amount: int = Field(default=0, ge=0, description="固定费用")
    ranking_status: int = Field(default=0, ge=0, le=1, description="重排状态")
    ranking_models: str = Field(..., max_length=200, description="重排模型")
    vector_models: str = Field(..., max_length=200, description="向量模型")
    chat_avatar: str = Field(..., max_length=250, description="对话头像")
    search_mode: str = Field(default="similar", pattern=r"^(similar|full|mix)$", description="检索的模式")
    search_tokens: int = Field(..., ge=0, le=8000, description="检索引用上限")
    search_similar: float = Field(..., ge=0, description="检索相似度")
    ranking_score: float = Field(..., ge=0, description="重排相似度")

    class Config:
        json_schema_extra = {
            "example": {
                "status": 1,
                "auto_abstract": 0,
                "charge_method": 2,
                "charge_amount": 2,
                "ranking_status": 0,
                "ranking_models": "qianfan:bce-reranker-base",
                "vector_models": "zhipu:embedding-3",
                "chat_avatar": "https://xx.com/default.png",
                "search_mode": "similar",
                "search_tokens": 6000,
                "search_similar": 0.6,
                "ranking_score": 0.6
            }
        }


"""--------------- Separator ---------------"""


class DocsSettingVo(BaseModel):
    """ 文档配置Vo """
    status: int = Field(description="功能开关: [0=关, 1=开]")
    auto_abstract: int = Field(description="自动摘要: [0=否, 1=是]")
    charge_method: int = Field(description="收费方式: [0=免费, 1=模型, 2=固定]")
    charge_amount: int = Field(description="固定费用")
    ranking_status: int = Field(description="重排状态")
    ranking_models: str = Field(description="重排模型")
    vector_models: str = Field(description="向量模型")
    chat_avatar: str = Field(description="对话头像")
    search_mode: str = Field(description="检索的模式")
    search_tokens: int = Field(description="检索引用上限")
    search_similar: float = Field(description="检索相似度")
    ranking_score: float = Field(description="重排相似度")

    class Config:
        json_schema_extra = {
            "example": {
                "status": 1,
                "auto_abstract": 0,
                "charge_method": 2,
                "charge_amount": 2,
                "ranking_status": 0,
                "ranking_models": "qianfan:bce-reranker-base",
                "vector_models": "zhipu:embedding-3",
                "chat_avatar": "https://xx.com/default.png",
                "search_mode": "similar",
                "search_tokens": 6000,
                "search_similar": 0.6,
                "ranking_score": 0.6
            }
        }
